<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>toJson : 把json对象转换成json字符串</title>
    <script src="../angular.js"></script>
</head>
<body>
    <div ng-app="gg", ng-controller="ctrl">
        
    </div>
    
    <script>
        var mod = angular.module('gg', []);
        mod.controller('ctrl', ['$scope', function ($scope) {
            $scope.data = {'name':'gg'};
            console.log($scope.data);

            /*
            *localStorage.setItem : 将数据存入本地永久存储
            *angular.toJson : 把json对象转换成json字符串
            */
            localStorage.setItem('data', angular.toJson($scope.data));

        }])
    </script>
</body>
</html>